{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests\n",
    "import json\n",
    "import numpy as np\n",
    "import pickle\n",
    "from collections import defaultdict"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# KODI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def get_tvshows() -> dict:\n",
    "    # 从服务器获取电视剧信息\n",
    "    url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "    parameters = {\n",
    "                  \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetTVShows\", \n",
    "                  \"params\": { \n",
    "                      \"properties\": [ \"title\", \"originaltitle\",  \"playcount\", \"file\", \"season\", \"episode\"], \n",
    "                      \"sort\": { \"order\": \"ascending\", \"method\": \"label\" } \n",
    "                  }, \n",
    "                  \"id\": \"libTvShows\"\n",
    "                 }\n",
    "    json_all_tvshows = requests.post(url,json=parameters,auth=(\"kodi\",\"kodi\")).json()\n",
    "    dict_all_tvshows = dict()\n",
    "    for itvshow in json_all_tvshows['result']['tvshows']:\n",
    "        # store tvshowid , number of seasons, number of total episode\n",
    "        tvshow_info = dict()\n",
    "        tvshow_info['basic'] = ((itvshow['tvshowid'],itvshow['season'],itvshow['episode']))\n",
    "        # get all episode id into a array\n",
    "        parameters2 = {\n",
    "                  \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetEpisodes\", \n",
    "                  \"params\": { \n",
    "                      \"tvshowid\":itvshow['tvshowid'],\n",
    "                      \"properties\": [\"title\", \"originaltitle\", \"season\", \"file\",\"episode\",\"showtitle\"], \n",
    "    #                   \"limits\": { \"start\" : 0, \"end\": 75 }, \n",
    "                      \"sort\": { \"order\": \"ascending\", \"method\": \"label\" } \n",
    "                  }, \n",
    "                  \"id\": \"libEpisodes\"\n",
    "                 }\n",
    "        json_episodes = requests.post(url,json=parameters2,auth=(\"kodi\",\"kodi\")).json()\n",
    "    #    print(itvshow['title'],json_episodes['result'].keys())\n",
    "    #     episodes_id = np.zeros((itvshow['season'],itvshow['episode']))\n",
    "        try:\n",
    "            episodes = [(iepisode['season'],iepisode['episode'],iepisode['episodeid']) for iepisode in json_episodes['result']['episodes']]\n",
    "            tvshow_info['detail'] = episodes\n",
    "            episodes_index = defaultdict(list)\n",
    "            for ie in episodes:\n",
    "                if ie[1] == len(episodes_index[f\"{ie[0]:04d}\"])+1:\n",
    "                    episodes_index[f\"{ie[0]:04d}\"].append(ie[2])\n",
    "                else:\n",
    "                    # 如果下一个的episode和已经存储的不连续，那么先添加-1填充\n",
    "                    for i in range(ie[1] - len(episodes_index[f\"{ie[0]:04d}\"]) -1 ):\n",
    "                        episodes_index[f\"{ie[0]:04d}\"].append(-1)\n",
    "                    episodes_index[f\"{ie[0]:04d}\"].append(ie[2])\n",
    "\n",
    "            tvshow_info['index'] = episodes_index        \n",
    "            dict_all_tvshows[itvshow['title']] = tvshow_info   \n",
    "        except Exception as e:\n",
    "            print(itvshow['title'])\n",
    "            print(e.message)\n",
    "    return dict_all_tvshows\n",
    "\n",
    "\n",
    "def store(data):\n",
    "    # save result\n",
    "    with open(\"dict_all_tvshows\",\"wb\") as f:\n",
    "        pickle.dump(data,f)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "dict_all_tvshows = get_tvshows()\n",
    "# store(dict_all_tvshows)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'basic': (21, 9, 171),\n",
       " 'detail': [(1, 1, 802),\n",
       "  (1, 2, 803),\n",
       "  (1, 3, 804),\n",
       "  (1, 4, 805),\n",
       "  (1, 5, 806),\n",
       "  (2, 1, 807),\n",
       "  (2, 2, 808),\n",
       "  (2, 3, 809),\n",
       "  (2, 4, 810),\n",
       "  (2, 5, 811),\n",
       "  (2, 6, 812),\n",
       "  (2, 7, 813),\n",
       "  (2, 8, 814),\n",
       "  (2, 9, 815),\n",
       "  (2, 10, 816),\n",
       "  (2, 11, 817),\n",
       "  (2, 12, 818),\n",
       "  (3, 1, 819),\n",
       "  (3, 2, 820),\n",
       "  (3, 3, 821),\n",
       "  (3, 4, 822),\n",
       "  (3, 5, 823),\n",
       "  (3, 6, 824),\n",
       "  (3, 7, 825),\n",
       "  (3, 8, 826),\n",
       "  (3, 9, 827),\n",
       "  (3, 10, 828),\n",
       "  (3, 11, 829),\n",
       "  (3, 12, 830),\n",
       "  (3, 13, 831),\n",
       "  (3, 14, 832),\n",
       "  (3, 15, 833),\n",
       "  (3, 16, 834),\n",
       "  (3, 17, 835),\n",
       "  (3, 18, 836),\n",
       "  (3, 19, 837),\n",
       "  (3, 20, 838),\n",
       "  (3, 21, 839),\n",
       "  (3, 22, 840),\n",
       "  (4, 1, 841),\n",
       "  (4, 2, 842),\n",
       "  (4, 3, 843),\n",
       "  (4, 4, 844),\n",
       "  (4, 5, 845),\n",
       "  (4, 6, 846),\n",
       "  (4, 7, 847),\n",
       "  (4, 8, 848),\n",
       "  (4, 9, 849),\n",
       "  (4, 10, 850),\n",
       "  (4, 11, 851),\n",
       "  (4, 12, 852),\n",
       "  (4, 13, 853),\n",
       "  (4, 14, 854),\n",
       "  (4, 15, 855),\n",
       "  (4, 16, 856),\n",
       "  (4, 17, 857),\n",
       "  (4, 18, 858),\n",
       "  (4, 19, 859),\n",
       "  (4, 20, 860),\n",
       "  (4, 21, 861),\n",
       "  (4, 22, 862),\n",
       "  (5, 1, 863),\n",
       "  (5, 2, 864),\n",
       "  (5, 3, 865),\n",
       "  (5, 4, 866),\n",
       "  (5, 5, 867),\n",
       "  (5, 6, 868),\n",
       "  (5, 7, 869),\n",
       "  (5, 8, 870),\n",
       "  (5, 9, 871),\n",
       "  (5, 10, 872),\n",
       "  (5, 11, 873),\n",
       "  (5, 12, 874),\n",
       "  (5, 13, 875),\n",
       "  (5, 14, 876),\n",
       "  (5, 15, 877),\n",
       "  (5, 16, 878),\n",
       "  (5, 17, 879),\n",
       "  (5, 18, 880),\n",
       "  (5, 19, 881),\n",
       "  (5, 20, 882),\n",
       "  (5, 21, 883),\n",
       "  (6, 1, 884),\n",
       "  (6, 2, 885),\n",
       "  (6, 3, 886),\n",
       "  (6, 4, 887),\n",
       "  (6, 5, 888),\n",
       "  (6, 6, 889),\n",
       "  (6, 7, 890),\n",
       "  (6, 8, 891),\n",
       "  (6, 9, 892),\n",
       "  (6, 10, 893),\n",
       "  (6, 11, 894),\n",
       "  (6, 12, 895),\n",
       "  (6, 13, 896),\n",
       "  (6, 14, 897),\n",
       "  (6, 15, 898),\n",
       "  (6, 16, 899),\n",
       "  (6, 17, 900),\n",
       "  (6, 18, 901),\n",
       "  (6, 19, 902),\n",
       "  (6, 20, 903),\n",
       "  (6, 21, 904),\n",
       "  (6, 22, 905),\n",
       "  (6, 23, 906),\n",
       "  (7, 1, 907),\n",
       "  (7, 2, 908),\n",
       "  (7, 3, 909),\n",
       "  (7, 4, 910),\n",
       "  (7, 5, 911),\n",
       "  (7, 6, 912),\n",
       "  (7, 7, 913),\n",
       "  (7, 8, 914),\n",
       "  (7, 9, 915),\n",
       "  (7, 10, 916),\n",
       "  (7, 11, 917),\n",
       "  (7, 12, 918),\n",
       "  (7, 13, 919),\n",
       "  (7, 14, 920),\n",
       "  (7, 15, 921),\n",
       "  (7, 16, 922),\n",
       "  (7, 17, 923),\n",
       "  (7, 18, 924),\n",
       "  (7, 19, 925),\n",
       "  (7, 20, 926),\n",
       "  (7, 21, 927),\n",
       "  (7, 22, 928),\n",
       "  (8, 1, 929),\n",
       "  (8, 2, 930),\n",
       "  (8, 3, 931),\n",
       "  (8, 4, 932),\n",
       "  (8, 5, 933),\n",
       "  (8, 6, 934),\n",
       "  (8, 7, 935),\n",
       "  (8, 8, 936),\n",
       "  (8, 9, 937),\n",
       "  (8, 10, 938),\n",
       "  (8, 11, 939),\n",
       "  (8, 12, 940),\n",
       "  (8, 13, 941),\n",
       "  (8, 14, 942),\n",
       "  (8, 15, 943),\n",
       "  (8, 16, 944),\n",
       "  (8, 17, 945),\n",
       "  (8, 18, 946),\n",
       "  (8, 19, 947),\n",
       "  (8, 20, 948),\n",
       "  (8, 21, 949),\n",
       "  (8, 22, 950),\n",
       "  (9, 1, 951),\n",
       "  (9, 2, 952),\n",
       "  (9, 3, 953),\n",
       "  (9, 4, 954),\n",
       "  (9, 5, 955),\n",
       "  (9, 6, 956),\n",
       "  (9, 7, 957),\n",
       "  (9, 8, 958),\n",
       "  (9, 9, 959),\n",
       "  (9, 10, 960),\n",
       "  (9, 11, 961),\n",
       "  (9, 12, 962),\n",
       "  (9, 13, 963),\n",
       "  (9, 14, 964),\n",
       "  (9, 15, 965),\n",
       "  (9, 16, 966),\n",
       "  (9, 17, 967),\n",
       "  (9, 18, 968),\n",
       "  (9, 19, 969),\n",
       "  (9, 20, 970),\n",
       "  (9, 21, 971),\n",
       "  (9, 22, 972)],\n",
       " 'index': defaultdict(list,\n",
       "             {'0001': [802, 803, 804, 805, 806],\n",
       "              '0002': [807,\n",
       "               808,\n",
       "               809,\n",
       "               810,\n",
       "               811,\n",
       "               812,\n",
       "               813,\n",
       "               814,\n",
       "               815,\n",
       "               816,\n",
       "               817,\n",
       "               818],\n",
       "              '0003': [819,\n",
       "               820,\n",
       "               821,\n",
       "               822,\n",
       "               823,\n",
       "               824,\n",
       "               825,\n",
       "               826,\n",
       "               827,\n",
       "               828,\n",
       "               829,\n",
       "               830,\n",
       "               831,\n",
       "               832,\n",
       "               833,\n",
       "               834,\n",
       "               835,\n",
       "               836,\n",
       "               837,\n",
       "               838,\n",
       "               839,\n",
       "               840],\n",
       "              '0004': [841,\n",
       "               842,\n",
       "               843,\n",
       "               844,\n",
       "               845,\n",
       "               846,\n",
       "               847,\n",
       "               848,\n",
       "               849,\n",
       "               850,\n",
       "               851,\n",
       "               852,\n",
       "               853,\n",
       "               854,\n",
       "               855,\n",
       "               856,\n",
       "               857,\n",
       "               858,\n",
       "               859,\n",
       "               860,\n",
       "               861,\n",
       "               862],\n",
       "              '0005': [863,\n",
       "               864,\n",
       "               865,\n",
       "               866,\n",
       "               867,\n",
       "               868,\n",
       "               869,\n",
       "               870,\n",
       "               871,\n",
       "               872,\n",
       "               873,\n",
       "               874,\n",
       "               875,\n",
       "               876,\n",
       "               877,\n",
       "               878,\n",
       "               879,\n",
       "               880,\n",
       "               881,\n",
       "               882,\n",
       "               883],\n",
       "              '0006': [884,\n",
       "               885,\n",
       "               886,\n",
       "               887,\n",
       "               888,\n",
       "               889,\n",
       "               890,\n",
       "               891,\n",
       "               892,\n",
       "               893,\n",
       "               894,\n",
       "               895,\n",
       "               896,\n",
       "               897,\n",
       "               898,\n",
       "               899,\n",
       "               900,\n",
       "               901,\n",
       "               902,\n",
       "               903,\n",
       "               904,\n",
       "               905,\n",
       "               906],\n",
       "              '0007': [907,\n",
       "               908,\n",
       "               909,\n",
       "               910,\n",
       "               911,\n",
       "               912,\n",
       "               913,\n",
       "               914,\n",
       "               915,\n",
       "               916,\n",
       "               917,\n",
       "               918,\n",
       "               919,\n",
       "               920,\n",
       "               921,\n",
       "               922,\n",
       "               923,\n",
       "               924,\n",
       "               925,\n",
       "               926,\n",
       "               927,\n",
       "               928],\n",
       "              '0008': [929,\n",
       "               930,\n",
       "               931,\n",
       "               932,\n",
       "               933,\n",
       "               934,\n",
       "               935,\n",
       "               936,\n",
       "               937,\n",
       "               938,\n",
       "               939,\n",
       "               940,\n",
       "               941,\n",
       "               942,\n",
       "               943,\n",
       "               944,\n",
       "               945,\n",
       "               946,\n",
       "               947,\n",
       "               948,\n",
       "               949,\n",
       "               950],\n",
       "              '0009': [951,\n",
       "               952,\n",
       "               953,\n",
       "               954,\n",
       "               955,\n",
       "               956,\n",
       "               957,\n",
       "               958,\n",
       "               959,\n",
       "               960,\n",
       "               961,\n",
       "               962,\n",
       "               963,\n",
       "               964,\n",
       "               965,\n",
       "               966,\n",
       "               967,\n",
       "               968,\n",
       "               969,\n",
       "               970,\n",
       "               971,\n",
       "               972]})}"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_all_tvshows[\"宋飞正传\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_data():\n",
    "    with open(\"dict_all_tvshows\",\"rb\") as f:\n",
    "        result = pickle.load(f)\n",
    "    return result\n",
    "\n",
    "dict_all_tvshows = read_data()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def calc_index(data):\n",
    "    # calculate the index for dict_all_tvshows\n",
    "    for ishow in data:\n",
    "        episodes = defaultdict(list)\n",
    "        for ie in data[ishow]['detail']:\n",
    "            if ie[1] == len(episodes[f\"{ie[0]:04d}\"])+1:\n",
    "                episodes[f\"{ie[0]:04d}\"].append(ie[2])\n",
    "            else:\n",
    "                # 如果下一个的episode和已经存储的不连续，那么先添加-1填充\n",
    "                for i in range(ie[1] - len(episodes[f\"{ie[0]:04d}\"]) -1 ):\n",
    "                    episodes[f\"{ie[0]:04d}\"].append(-1)\n",
    "                episodes[f\"{ie[0]:04d}\"].append(ie[2])\n",
    "\n",
    "        data[ishow]['index'] = episodes\n",
    "    return data\n",
    "\n",
    "dict_all_tvshows = calc_index(dict_all_tvshows)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['9号秘事', '与霍金一起了解宇宙', '了不起的麦瑟尔夫人', '使女的故事', '全裸导演', '冰血暴', '副总统', '十二猴子', '城堡岩', '大明王朝1566', '大西洋帝国', '奥丽芙·基特里奇', '好汉两个半', '孤独的美食家', '宋飞正传', '小谢尔顿', '怪奇物语', '恶搞之家', '摩登家庭', '斯巴达克斯', '无人生还', '早间新闻', '是，大臣', '是，首相', '最完美的离婚', '权力的游戏', '毒枭', '深夜食堂', '火线', '爱，死亡和机器人', '特工科恩', '王朝', '瑞克和莫蒂', '生活大爆炸', '真探', '硅谷', '神探夏洛克', '禁忌', '红楼梦', '纸牌屋', '绝命毒师', '维多利亚的秘密时尚秀', '罗马', '老友记', '老爸老妈的浪漫史', '致命女人', '走向共和', '越野千里', '降世神通：最后的气宗', '降世神通：科拉传奇', '风骚律师', '飞出个未来', '飞天大盗', '马男波杰克', '黑吃黑', '黑道家族', '黑钱胜地', '黑镜'])"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dict_all_tvshows.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['limits', 'tvshows'])"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "{'end': 39, 'start': 0, 'total': 39}"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "[(26, '9号秘事', 3, 18),\n",
       " (9, 'silicon vally', 6, 53),\n",
       " (30, '与霍金一起了解宇宙', 1, 1),\n",
       " (39, '副总统', 6, 56),\n",
       " (1, '十二猴子', 1, 13),\n",
       " (4, '大明王朝1566', 1, 46),\n",
       " (38, '大西洋帝国', 5, 56),\n",
       " (23, '奥丽芙·基特里奇', 1, 4),\n",
       " (3, '孤独的美食家', 1, 12),\n",
       " (6, '宋飞正传', 9, 171),\n",
       " (36, '小谢尔顿', 2, 31),\n",
       " (8, '怪奇物语', 1, 8),\n",
       " (19, '斯巴达克斯', 3, 32),\n",
       " (33, '早间新闻', 1, 10),\n",
       " (12, '是，大臣', 3, 44),\n",
       " (28, '是，首相', 3, 17),\n",
       " (16, '最完美的离婚', 2, 13),\n",
       " (24, '权力的游戏', 8, 73),\n",
       " (11, '深夜食堂', 3, 40),\n",
       " (27, '深夜食堂', 4, 50),\n",
       " (18, '火线', 5, 60),\n",
       " (17, '爱，死亡和机器人', 1, 18),\n",
       " (32, '王朝', 1, 5),\n",
       " (34, '生活大爆炸', 4, 79),\n",
       " (7, '神探夏洛克', 1, 6),\n",
       " (2, '红楼梦', 1, 76),\n",
       " (20, '纸牌屋', 5, 59),\n",
       " (5, '维多利亚的秘密时尚秀', 1, 11),\n",
       " (13, '老友记', 10, 234),\n",
       " (15, '老爸老妈的浪漫史', 0, 0),\n",
       " (31, '致命女人', 1, 10),\n",
       " (10, '走向共和', 2, 70),\n",
       " (14, '降世神通：最后的气宗', 3, 39),\n",
       " (37, '降世神通：科拉传奇', 4, 52),\n",
       " (29, '风骚律师', 5, 49),\n",
       " (22, '飞出个未来', 5, 78),\n",
       " (25, '马男波杰克', 1, 22),\n",
       " (21, '黑吃黑', 2, 40),\n",
       " (35, '黑道家族', 6, 86)]"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result['result'].keys()\n",
    "result['result']['limits']\n",
    "[(i['tvshowid'],i['title'],i['season'],i['episode']) for i in result['result']['tvshows']]\n",
    "# set([i['tvshowid'] for i in result['result']['tvshows']])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'episode': 1,\n",
       "  'episodeid': 313,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E01.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x01. 硅谷.Silicon.Valley.S01E01.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E01.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 314,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E02.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x02. 硅谷.Silicon.Valley.S01E02.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E02.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 315,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E03.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x03. 硅谷.Silicon.Valley.S01E03.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E03.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 316,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E04.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x04. 硅谷.Silicon.Valley.S01E04.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E04.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 317,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E05.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x05. 硅谷.Silicon.Valley.S01E05.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E05.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 318,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E06.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x06. 硅谷.Silicon.Valley.S01E06.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E06.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 319,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E07.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x07. 硅谷.Silicon.Valley.S01E07.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E07.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 8,\n",
       "  'episodeid': 320,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S01/硅谷.Silicon.Valley.S01E08.2014.BD.MiniSD-TLF.mkv',\n",
       "  'label': '1x08. 硅谷.Silicon.Valley.S01E08.2014.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 1,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S01E08.2014.BD.MiniSD-TLF'},\n",
       " {'episode': 1,\n",
       "  'episodeid': 321,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E01.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x01. 硅谷.Silicon.Valley.S02E01.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E01.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 322,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E02.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x02. 硅谷.Silicon.Valley.S02E02.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E02.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 323,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E03.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x03. 硅谷.Silicon.Valley.S02E03.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E03.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 324,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E04.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x04. 硅谷.Silicon.Valley.S02E04.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E04.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 325,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E05.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x05. 硅谷.Silicon.Valley.S02E05.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E05.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 326,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E06.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x06. 硅谷.Silicon.Valley.S02E06.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E06.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 327,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E07.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x07. 硅谷.Silicon.Valley.S02E07.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E07.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 8,\n",
       "  'episodeid': 328,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E08.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x08. 硅谷.Silicon.Valley.S02E08.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E08.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 9,\n",
       "  'episodeid': 329,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E09.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x09. 硅谷.Silicon.Valley.S02E09.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E09.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 10,\n",
       "  'episodeid': 330,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S02/硅谷.Silicon.Valley.S02E10.2015.BD.MiniSD-TLF.mkv',\n",
       "  'label': '2x10. 硅谷.Silicon.Valley.S02E10.2015.BD.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 2,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S02E10.2015.BD.MiniSD-TLF'},\n",
       " {'episode': 1,\n",
       "  'episodeid': 331,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E01.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x01. 硅谷.第3季.Silicon.Valley.S03E01.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E01.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 332,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E02.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x02. 硅谷.第3季.Silicon.Valley.S03E02.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E02.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 333,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E03.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x03. 硅谷.第3季.Silicon.Valley.S03E03.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E03.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 334,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E04.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x04. 硅谷.第3季.Silicon.Valley.S03E04.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E04.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 335,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E05.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x05. 硅谷.第3季.Silicon.Valley.S03E05.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E05.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 336,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E06.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x06. 硅谷.第3季.Silicon.Valley.S03E06.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E06.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 337,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E07.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x07. 硅谷.第3季.Silicon.Valley.S03E07.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E07.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 8,\n",
       "  'episodeid': 338,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E08.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x08. 硅谷.第3季.Silicon.Valley.S03E08.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E08.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 9,\n",
       "  'episodeid': 339,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E09.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x09. 硅谷.第3季.Silicon.Valley.S03E09.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E09.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 10,\n",
       "  'episodeid': 340,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S03/硅谷.第3季.Silicon.Valley.S03E10.2016.HDTV.MiniHD-TLF.mkv',\n",
       "  'label': '3x10. 硅谷.第3季.Silicon.Valley.S03E10.2016.HDTV.MiniHD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 3,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.第3季.Silicon.Valley.S03E10.2016.HDTV.MiniHD-TLF'},\n",
       " {'episode': 1,\n",
       "  'episodeid': 303,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E01.Success.Failure.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x01. 硅谷.Silicon.Valley.S04E01.Success.Failure.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E01.Success.Failure.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 304,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E02.Terms.Of.Service.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x02. 硅谷.Silicon.Valley.S04E02.Terms.Of.Service.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E02.Terms.Of.Service.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 305,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E03.Intellectual.Property.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x03. 硅谷.Silicon.Valley.S04E03.Intellectual.Property.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E03.Intellectual.Property.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 306,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E04.Teambuilding.Exercise.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x04. 硅谷.Silicon.Valley.S04E04.Teambuilding.Exercise.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E04.Teambuilding.Exercise.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 307,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E05.The.Blood.Boy.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x05. 硅谷.Silicon.Valley.S04E05.The.Blood.Boy.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E05.The.Blood.Boy.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 308,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E06.Customer.Service.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x06. 硅谷.Silicon.Valley.S04E06.Customer.Service.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E06.Customer.Service.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 309,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E07.The.Patent.Troll.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x07. 硅谷.Silicon.Valley.S04E07.The.Patent.Troll.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E07.The.Patent.Troll.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 8,\n",
       "  'episodeid': 310,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E08.The.Keenan.Vortex.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x08. 硅谷.Silicon.Valley.S04E08.The.Keenan.Vortex.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E08.The.Keenan.Vortex.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 9,\n",
       "  'episodeid': 311,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E09.Hooli-Con.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x09. 硅谷.Silicon.Valley.S04E09.Hooli-Con.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E09.Hooli-Con.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 10,\n",
       "  'episodeid': 312,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/Silicon.Valley.S04.2017.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S04E10.Server.Error.2017.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '4x10. 硅谷.Silicon.Valley.S04E10.Server.Error.2017.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 4,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S04E10.Server.Error.2017.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 1,\n",
       "  'episodeid': 341,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E01.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x01. 硅谷.Silicon.Valley.S05E01.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E01.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 342,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E02.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x02. 硅谷.Silicon.Valley.S05E02.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E02.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 343,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E03.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x03. 硅谷.Silicon.Valley.S05E03.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E03.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 344,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E04.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x04. 硅谷.Silicon.Valley.S05E04.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E04.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 345,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E05.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x05. 硅谷.Silicon.Valley.S05E05.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E05.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 346,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E06.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x06. 硅谷.Silicon.Valley.S05E06.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E06.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 347,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E07.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x07. 硅谷.Silicon.Valley.S05E07.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E07.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 8,\n",
       "  'episodeid': 348,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S05.2018.WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S05E08.2018.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '5x08. 硅谷.Silicon.Valley.S05E08.2018.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 5,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S05E08.2018.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 1,\n",
       "  'episodeid': 349,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E01.Artificial.Lack.of.Intelligence.2019..WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x01. 硅谷.Silicon.Valley.S06E01.Artificial.Lack.of.Intelligence.2019..WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E01.Artificial.Lack.of.Intelligence.2019..WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 2,\n",
       "  'episodeid': 350,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E02.Blood.Money.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x02. 硅谷.Silicon.Valley.S06E02.Blood.Money.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E02.Blood.Money.2019.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 3,\n",
       "  'episodeid': 351,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E03.Hooli.Smokes.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x03. 硅谷.Silicon.Valley.S06E03.Hooli.Smokes.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E03.Hooli.Smokes.2019.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 4,\n",
       "  'episodeid': 352,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E04.Maximizing.Alphaness.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x04. 硅谷.Silicon.Valley.S06E04.Maximizing.Alphaness.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E04.Maximizing.Alphaness.2019.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 5,\n",
       "  'episodeid': 353,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E05.Tethics.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x05. 硅谷.Silicon.Valley.S06E05.Tethics.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E05.Tethics.2019.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 6,\n",
       "  'episodeid': 354,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E06.RussFest.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x06. 硅谷.Silicon.Valley.S06E06.RussFest.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E06.RussFest.2019.WEB-DL.MiniSD-TLF'},\n",
       " {'episode': 7,\n",
       "  'episodeid': 355,\n",
       "  'file': 'nfs://192.168.2.164/mnt/sata1/剧集/silicon.vally.硅谷/硅谷.Silicon.Valley.S06.2019..WEB-DL.MiniSD-TLF/硅谷.Silicon.Valley.S06E07.Exit.Event.2019.WEB-DL.MiniSD-TLF.mkv',\n",
       "  'label': '6x07. 硅谷.Silicon.Valley.S06E07.Exit.Event.2019.WEB-DL.MiniSD-TLF',\n",
       "  'originaltitle': '',\n",
       "  'season': 6,\n",
       "  'showtitle': 'silicon vally',\n",
       "  'title': '硅谷.Silicon.Valley.S06E07.Exit.Event.2019.WEB-DL.MiniSD-TLF'}]"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/plain": [
       "{'end': 53, 'start': 0, 'total': 53}"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result2['result']['episodes']\n",
    "result2['result']['limits']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "def play_episode(episodeid: int) -> str:\n",
    "    url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "    parameters3 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \n",
    "              \"params\": {\n",
    "                  \"item\":{\"episodeid\":episodeid}                  \n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "    result3= requests.post(url,json=parameters3,auth=(\"kodi\",\"kodi\")).json()\n",
    "    return result3['result']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "parameters = {\n",
    "                  \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetMovies\", \n",
    "                  \"params\": { \n",
    "                      \"properties\": [ \"title\", \"lastplayed\",  \"playcount\", \"file\", \"setid\"], \n",
    "                      \"sort\": { \"order\": \"ascending\", \"method\": \"label\" } \n",
    "                  }, \n",
    "                  \"id\": \"libTvShows\"\n",
    "                 }\n",
    "result3= requests.post(url,json=parameters,auth=(\"kodi\",\"kodi\")).json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [],
   "source": [
    "movies = [(im['file'],im['movieid']) for im in result3['result'][\"movies\"]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "nfs://192.168.2.164/mnt/sata1/电影/starter.mp4 231\n"
     ]
    }
   ],
   "source": [
    "for ifile,iid in movies:\n",
    "    if \"starter\" in ifile:\n",
    "        print(ifile,iid)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 'OK'}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "# time.sleep(5)\n",
    "parameters3 = {\n",
    "          \"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \n",
    "          \"params\": {\n",
    "              \"item\":{\"movieid\":230}                  \n",
    "            }, \n",
    "          \"id\": 1\n",
    "         }\n",
    "\n",
    "result3= requests.post(url,json=parameters3,auth=(\"kodi\",\"kodi\")).json()\n",
    "result3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1,\n",
       " 'jsonrpc': '2.0',\n",
       " 'result': {'episodedetails': {'episode': 2,\n",
       "   'episodeid': 1735,\n",
       "   'firstaired': '1969-12-31',\n",
       "   'label': '火线.The.Wire.S02E02.2003.D9.3Audio.MiniSD-TLF',\n",
       "   'resume': {'position': 272.0, 'total': 3517.0},\n",
       "   'season': 2,\n",
       "   'title': '火线.The.Wire.S02E02.2003.D9.3Audio.MiniSD-TLF'}}}"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 获取已播放时间\n",
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.GetEpisodeDetails\", \n",
    "              \"params\": {\n",
    "                  \"episodeid\":1735,\n",
    "                  \"properties\":[\"title\",\"resume\",\"firstaired\",\"season\",\"episode\"]\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'error': {'code': -32100, 'message': 'Failed to execute method.'},\n",
       " 'id': 1,\n",
       " 'jsonrpc': '2.0'}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 继续播放,中间需要暂停一下\n",
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "# parameters3 = {\n",
    "#               \"jsonrpc\": \"2.0\", \"method\": \"Player.Open\", \n",
    "#               \"params\": {\n",
    "#                   \"item\":{\"episodeid\":1735}                  \n",
    "#                 }, \n",
    "#               \"id\": 1\n",
    "#              }\n",
    "# result3= requests.post(url,json=parameters3,auth=(\"kodi\",\"kodi\")).json()\n",
    "# print(result3)\n",
    "parameters3 = {\n",
    "          \"jsonrpc\": \"2.0\", \"method\": \"Player.Seek\", \n",
    "          \"params\": {\n",
    "              \"playerid\":1,\n",
    "              \"value\":{\"seconds\":227}                  \n",
    "            }, \n",
    "          \"id\": 1\n",
    "         }\n",
    "\n",
    "result3= requests.post(url,json=parameters3,auth=(\"kodi\",\"kodi\")).json()\n",
    "result3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\"result\" in result3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1,\n",
       " 'jsonrpc': '2.0',\n",
       " 'result': [{'playerid': 1, 'playertype': 'internal', 'type': 'video'}]}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \n",
    "              \"params\": {\n",
    "                  \n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': {'volume': 80}}"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Application.GetProperties\", \n",
    "              \"params\": {\n",
    "                  \"properties\":[\"volume\"]\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 100}"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Application.SetVolume\", \n",
    "              \"params\": {\n",
    "                  \"volume\":100\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 'OK'}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"GUI.ActivateWindow\", \n",
    "              \"params\": {\n",
    "                  \"window\":\"contextmenu\"\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 'OK'}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"INPUT.Down\", \n",
    "              \"params\": {\n",
    "                  \n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'error': {'code': -32602,\n",
       "  'data': {'method': 'Player.GetItem',\n",
       "   'stack': {'message': 'array element at index 6 does not match',\n",
       "    'name': 'Item.Fields.Base',\n",
       "    'property': {'message': 'Received value does not match any of the defined enum values',\n",
       "     'type': 'string'},\n",
       "    'type': 'array'}},\n",
       "  'message': 'Invalid params.'},\n",
       " 'id': 1,\n",
       " 'jsonrpc': '2.0'}"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \n",
    "              \"params\": {\n",
    "                  \"playerid\":1,\n",
    "                  \"properties\":[\"title\", \"originaltitle\", \"season\", \"file\",\"episode\",\"showtitle\"]\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1,\n",
       " 'jsonrpc': '2.0',\n",
       " 'result': {'channelgroups': [{'channelgroupid': 2,\n",
       "    'channeltype': 'tv',\n",
       "    'label': '全部频道'},\n",
       "   {'channelgroupid': 23, 'channeltype': 'tv', 'label': '央视频道'},\n",
       "   {'channelgroupid': 24, 'channeltype': 'tv', 'label': '卫视频道'},\n",
       "   {'channelgroupid': 25, 'channeltype': 'tv', 'label': '电影频道'},\n",
       "   {'channelgroupid': 26, 'channeltype': 'tv', 'label': '体育电竞'},\n",
       "   {'channelgroupid': 27, 'channeltype': 'tv', 'label': '综艺财经'},\n",
       "   {'channelgroupid': 28, 'channeltype': 'tv', 'label': '电视剧频道'},\n",
       "   {'channelgroupid': 29, 'channeltype': 'tv', 'label': '动画频道'}],\n",
       "  'limits': {'end': 8, 'start': 0, 'total': 8}}}"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"PVR.GetChannelGroups\", \n",
    "              \"params\": {\n",
    "                  \"channeltype\":\"tv\",\n",
    "#                   \"properties\":[\"channel\", \"channelnumber\", \"subchannelnumber\"]\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1,\n",
       " 'jsonrpc': '2.0',\n",
       " 'result': {'channels': [{'channel': 'CCTV1',\n",
       "    'channelid': 1723,\n",
       "    'channelnumber': 1,\n",
       "    'label': 'CCTV1',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV2',\n",
       "    'channelid': 1742,\n",
       "    'channelnumber': 2,\n",
       "    'label': 'CCTV2',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV3',\n",
       "    'channelid': 1695,\n",
       "    'channelnumber': 3,\n",
       "    'label': 'CCTV3',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV4',\n",
       "    'channelid': 1733,\n",
       "    'channelnumber': 4,\n",
       "    'label': 'CCTV4',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV5',\n",
       "    'channelid': 1735,\n",
       "    'channelnumber': 5,\n",
       "    'label': 'CCTV5',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV5+',\n",
       "    'channelid': 1724,\n",
       "    'channelnumber': 6,\n",
       "    'label': 'CCTV5+',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV6',\n",
       "    'channelid': 1691,\n",
       "    'channelnumber': 7,\n",
       "    'label': 'CCTV6',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV7',\n",
       "    'channelid': 1758,\n",
       "    'channelnumber': 8,\n",
       "    'label': 'CCTV7',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV8',\n",
       "    'channelid': 1727,\n",
       "    'channelnumber': 9,\n",
       "    'label': 'CCTV8',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV9',\n",
       "    'channelid': 1698,\n",
       "    'channelnumber': 10,\n",
       "    'label': 'CCTV9',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV10',\n",
       "    'channelid': 1743,\n",
       "    'channelnumber': 11,\n",
       "    'label': 'CCTV10',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV11',\n",
       "    'channelid': 1713,\n",
       "    'channelnumber': 12,\n",
       "    'label': 'CCTV11',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV12',\n",
       "    'channelid': 1693,\n",
       "    'channelnumber': 13,\n",
       "    'label': 'CCTV12',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV13',\n",
       "    'channelid': 1730,\n",
       "    'channelnumber': 14,\n",
       "    'label': 'CCTV13',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV14',\n",
       "    'channelid': 1707,\n",
       "    'channelnumber': 15,\n",
       "    'label': 'CCTV14',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV15',\n",
       "    'channelid': 1721,\n",
       "    'channelnumber': 16,\n",
       "    'label': 'CCTV15',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTVNEWS',\n",
       "    'channelid': 1750,\n",
       "    'channelnumber': 17,\n",
       "    'label': 'CCTVNEWS',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '发现之旅',\n",
       "    'channelid': 1703,\n",
       "    'channelnumber': 18,\n",
       "    'label': '发现之旅',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '老故事',\n",
       "    'channelid': 1759,\n",
       "    'channelnumber': 19,\n",
       "    'label': '老故事',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '女性时尚',\n",
       "    'channelid': 1738,\n",
       "    'channelnumber': 20,\n",
       "    'label': '女性时尚',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '凤凰香港',\n",
       "    'channelid': 1689,\n",
       "    'channelnumber': 21,\n",
       "    'label': '凤凰香港',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '凤凰中文',\n",
       "    'channelid': 1705,\n",
       "    'channelnumber': 22,\n",
       "    'label': '凤凰中文',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '湖南卫视',\n",
       "    'channelid': 1747,\n",
       "    'channelnumber': 23,\n",
       "    'label': '湖南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '江苏卫视',\n",
       "    'channelid': 1702,\n",
       "    'channelnumber': 24,\n",
       "    'label': '江苏卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '浙江卫视',\n",
       "    'channelid': 1696,\n",
       "    'channelnumber': 25,\n",
       "    'label': '浙江卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '东方卫视',\n",
       "    'channelid': 1690,\n",
       "    'channelnumber': 26,\n",
       "    'label': '东方卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '北京卫视',\n",
       "    'channelid': 1700,\n",
       "    'channelnumber': 27,\n",
       "    'label': '北京卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '广东卫视',\n",
       "    'channelid': 1726,\n",
       "    'channelnumber': 28,\n",
       "    'label': '广东卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '深圳卫视',\n",
       "    'channelid': 1719,\n",
       "    'channelnumber': 29,\n",
       "    'label': '深圳卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '天津卫视',\n",
       "    'channelid': 1712,\n",
       "    'channelnumber': 30,\n",
       "    'label': '天津卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '重庆卫视',\n",
       "    'channelid': 1718,\n",
       "    'channelnumber': 31,\n",
       "    'label': '重庆卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '安徽卫视',\n",
       "    'channelid': 1757,\n",
       "    'channelnumber': 32,\n",
       "    'label': '安徽卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '山东卫视',\n",
       "    'channelid': 1736,\n",
       "    'channelnumber': 33,\n",
       "    'label': '山东卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '湖北卫视',\n",
       "    'channelid': 1704,\n",
       "    'channelnumber': 34,\n",
       "    'label': '湖北卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '辽宁卫视',\n",
       "    'channelid': 1749,\n",
       "    'channelnumber': 35,\n",
       "    'label': '辽宁卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '江西卫视',\n",
       "    'channelid': 1688,\n",
       "    'channelnumber': 36,\n",
       "    'label': '江西卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '河北卫视',\n",
       "    'channelid': 1744,\n",
       "    'channelnumber': 37,\n",
       "    'label': '河北卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '黑龙江卫视',\n",
       "    'channelid': 1751,\n",
       "    'channelnumber': 38,\n",
       "    'label': '黑龙江卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '东南卫视',\n",
       "    'channelid': 1711,\n",
       "    'channelnumber': 39,\n",
       "    'label': '东南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '四川卫视',\n",
       "    'channelid': 1746,\n",
       "    'channelnumber': 40,\n",
       "    'label': '四川卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '河南卫视',\n",
       "    'channelid': 1729,\n",
       "    'channelnumber': 41,\n",
       "    'label': '河南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '吉林卫视',\n",
       "    'channelid': 1716,\n",
       "    'channelnumber': 42,\n",
       "    'label': '吉林卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '山西卫视',\n",
       "    'channelid': 1737,\n",
       "    'channelnumber': 43,\n",
       "    'label': '山西卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '贵州卫视',\n",
       "    'channelid': 1709,\n",
       "    'channelnumber': 44,\n",
       "    'label': '贵州卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '青海卫视',\n",
       "    'channelid': 1706,\n",
       "    'channelnumber': 45,\n",
       "    'label': '青海卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '云南卫视',\n",
       "    'channelid': 1722,\n",
       "    'channelnumber': 46,\n",
       "    'label': '云南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '海南卫视',\n",
       "    'channelid': 1714,\n",
       "    'channelnumber': 47,\n",
       "    'label': '海南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV爱情喜剧',\n",
       "    'channelid': 1708,\n",
       "    'channelnumber': 48,\n",
       "    'label': 'NewTV爱情喜剧',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV搏击',\n",
       "    'channelid': 1745,\n",
       "    'channelnumber': 49,\n",
       "    'label': 'NewTV搏击',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV潮妈辣婆',\n",
       "    'channelid': 1741,\n",
       "    'channelnumber': 50,\n",
       "    'label': 'NewTV潮妈辣婆',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV动作电影',\n",
       "    'channelid': 1717,\n",
       "    'channelnumber': 51,\n",
       "    'label': 'NewTV动作电影',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV家庭剧场',\n",
       "    'channelid': 1732,\n",
       "    'channelnumber': 52,\n",
       "    'label': 'NewTV家庭剧场',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV健康有约',\n",
       "    'channelid': 1720,\n",
       "    'channelnumber': 53,\n",
       "    'label': 'NewTV健康有约',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV金牌综艺',\n",
       "    'channelid': 1715,\n",
       "    'channelnumber': 54,\n",
       "    'label': 'NewTV金牌综艺',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV惊悚悬疑',\n",
       "    'channelid': 1755,\n",
       "    'channelnumber': 55,\n",
       "    'label': 'NewTV惊悚悬疑',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV精品纪录',\n",
       "    'channelid': 1694,\n",
       "    'channelnumber': 56,\n",
       "    'label': 'NewTV精品纪录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV精品体育',\n",
       "    'channelid': 1731,\n",
       "    'channelnumber': 57,\n",
       "    'label': 'NewTV精品体育',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV军事评论',\n",
       "    'channelid': 1739,\n",
       "    'channelnumber': 58,\n",
       "    'label': 'NewTV军事评论',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV农业致富',\n",
       "    'channelid': 1752,\n",
       "    'channelnumber': 59,\n",
       "    'label': 'NewTV农业致富',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV古装剧场',\n",
       "    'channelid': 1692,\n",
       "    'channelnumber': 60,\n",
       "    'label': 'NewTV古装剧场',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'NewTV精品大剧',\n",
       "    'channelid': 1753,\n",
       "    'channelnumber': 61,\n",
       "    'label': 'NewTV精品大剧',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'Newtv超级电视剧',\n",
       "    'channelid': 1697,\n",
       "    'channelnumber': 62,\n",
       "    'label': 'Newtv超级电视剧',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '卡酷少儿',\n",
       "    'channelid': 1725,\n",
       "    'channelnumber': 63,\n",
       "    'label': '卡酷少儿',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '金鹰卡通',\n",
       "    'channelid': 1728,\n",
       "    'channelnumber': 64,\n",
       "    'label': '金鹰卡通',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '哈哈炫动',\n",
       "    'channelid': 1699,\n",
       "    'channelnumber': 65,\n",
       "    'label': '哈哈炫动',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '吉林篮球',\n",
       "    'channelid': 1754,\n",
       "    'channelnumber': 66,\n",
       "    'label': '吉林篮球',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '高尔夫',\n",
       "    'channelid': 1748,\n",
       "    'channelnumber': 67,\n",
       "    'label': '高尔夫',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '新娱乐',\n",
       "    'channelid': 1710,\n",
       "    'channelnumber': 68,\n",
       "    'label': '新娱乐',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '家庭理财',\n",
       "    'channelid': 1734,\n",
       "    'channelnumber': 69,\n",
       "    'label': '家庭理财',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '弈坛春秋',\n",
       "    'channelid': 1701,\n",
       "    'channelnumber': 70,\n",
       "    'label': '弈坛春秋',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '中国交通',\n",
       "    'channelid': 1756,\n",
       "    'channelnumber': 71,\n",
       "    'label': '中国交通',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '国学频道',\n",
       "    'channelid': 1740,\n",
       "    'channelnumber': 72,\n",
       "    'label': '国学频道',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '求索记录',\n",
       "    'channelid': 22,\n",
       "    'channelnumber': 73,\n",
       "    'label': '求索记录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '湖南卫视',\n",
       "    'channelid': 20,\n",
       "    'channelnumber': 74,\n",
       "    'label': '湖南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '江苏卫视',\n",
       "    'channelid': 10,\n",
       "    'channelnumber': 75,\n",
       "    'label': '江苏卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '浙江卫视',\n",
       "    'channelid': 28,\n",
       "    'channelnumber': 76,\n",
       "    'label': '浙江卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '东方卫视',\n",
       "    'channelid': 21,\n",
       "    'channelnumber': 77,\n",
       "    'label': '东方卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '北京卫视',\n",
       "    'channelid': 23,\n",
       "    'channelnumber': 78,\n",
       "    'label': '北京卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '广东卫视',\n",
       "    'channelid': 19,\n",
       "    'channelnumber': 79,\n",
       "    'label': '广东卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '深圳卫视',\n",
       "    'channelid': 33,\n",
       "    'channelnumber': 80,\n",
       "    'label': '深圳卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '天津卫视',\n",
       "    'channelid': 8,\n",
       "    'channelnumber': 81,\n",
       "    'label': '天津卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '安徽卫视',\n",
       "    'channelid': 16,\n",
       "    'channelnumber': 82,\n",
       "    'label': '安徽卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '山东卫视',\n",
       "    'channelid': 5,\n",
       "    'channelnumber': 83,\n",
       "    'label': '山东卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '湖北卫视',\n",
       "    'channelid': 15,\n",
       "    'channelnumber': 84,\n",
       "    'label': '湖北卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '辽宁卫视',\n",
       "    'channelid': 14,\n",
       "    'channelnumber': 85,\n",
       "    'label': '辽宁卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '江西卫视',\n",
       "    'channelid': 6,\n",
       "    'channelnumber': 86,\n",
       "    'label': '江西卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '河北卫视',\n",
       "    'channelid': 29,\n",
       "    'channelnumber': 87,\n",
       "    'label': '河北卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '黑龙江卫视',\n",
       "    'channelid': 26,\n",
       "    'channelnumber': 88,\n",
       "    'label': '黑龙江卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '四川卫视',\n",
       "    'channelid': 31,\n",
       "    'channelnumber': 89,\n",
       "    'label': '四川卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '广西卫视',\n",
       "    'channelid': 3,\n",
       "    'channelnumber': 90,\n",
       "    'label': '广西卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '河南卫视',\n",
       "    'channelid': 9,\n",
       "    'channelnumber': 91,\n",
       "    'label': '河南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '吉林卫视',\n",
       "    'channelid': 30,\n",
       "    'channelnumber': 92,\n",
       "    'label': '吉林卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '山西卫视',\n",
       "    'channelid': 27,\n",
       "    'channelnumber': 93,\n",
       "    'label': '山西卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '青海卫视',\n",
       "    'channelid': 11,\n",
       "    'channelnumber': 94,\n",
       "    'label': '青海卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '云南卫视',\n",
       "    'channelid': 7,\n",
       "    'channelnumber': 95,\n",
       "    'label': '云南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '宁夏卫视',\n",
       "    'channelid': 25,\n",
       "    'channelnumber': 96,\n",
       "    'label': '宁夏卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '新疆卫视',\n",
       "    'channelid': 18,\n",
       "    'channelnumber': 97,\n",
       "    'label': '新疆卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '海南卫视',\n",
       "    'channelid': 12,\n",
       "    'channelnumber': 98,\n",
       "    'label': '海南卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '内蒙古卫视',\n",
       "    'channelid': 17,\n",
       "    'channelnumber': 99,\n",
       "    'label': '内蒙古卫视',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CETV1',\n",
       "    'channelid': 24,\n",
       "    'channelnumber': 100,\n",
       "    'label': 'CETV1',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '动漫秀场',\n",
       "    'channelid': 2,\n",
       "    'channelnumber': 101,\n",
       "    'label': '动漫秀场',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '电竞世界',\n",
       "    'channelid': 13,\n",
       "    'channelnumber': 102,\n",
       "    'label': '电竞世界',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '极速汽车',\n",
       "    'channelid': 32,\n",
       "    'channelnumber': 103,\n",
       "    'label': '极速汽车',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': '纪实',\n",
       "    'channelid': 1,\n",
       "    'channelnumber': 104,\n",
       "    'label': '纪实',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'iPanda',\n",
       "    'channelid': 323,\n",
       "    'channelnumber': 105,\n",
       "    'label': 'iPanda',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1',\n",
       "    'channelid': 1173,\n",
       "    'channelnumber': 106,\n",
       "    'label': 'CCTV中国中央电视台-1',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1',\n",
       "    'channelid': 320,\n",
       "    'channelnumber': 107,\n",
       "    'label': 'CCTV中国中央电视台-1',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10',\n",
       "    'channelid': 239,\n",
       "    'channelnumber': 108,\n",
       "    'label': 'CCTV中国中央电视台-10',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10 科教',\n",
       "    'channelid': 1440,\n",
       "    'channelnumber': 109,\n",
       "    'label': 'CCTV中国中央电视台-10 科教',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10科教',\n",
       "    'channelid': 695,\n",
       "    'channelnumber': 110,\n",
       "    'label': 'CCTV中国中央电视台-10科教',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10高清',\n",
       "    'channelid': 1565,\n",
       "    'channelnumber': 111,\n",
       "    'label': 'CCTV中国中央电视台-10高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10高清',\n",
       "    'channelid': 1545,\n",
       "    'channelnumber': 112,\n",
       "    'label': 'CCTV中国中央电视台-10高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-10高清',\n",
       "    'channelid': 1672,\n",
       "    'channelnumber': 113,\n",
       "    'label': 'CCTV中国中央电视台-10高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11',\n",
       "    'channelid': 63,\n",
       "    'channelnumber': 114,\n",
       "    'label': 'CCTV中国中央电视台-11',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11',\n",
       "    'channelid': 207,\n",
       "    'channelnumber': 115,\n",
       "    'label': 'CCTV中国中央电视台-11',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11 戏曲',\n",
       "    'channelid': 1252,\n",
       "    'channelnumber': 116,\n",
       "    'label': 'CCTV中国中央电视台-11 戏曲',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11戏曲',\n",
       "    'channelid': 392,\n",
       "    'channelnumber': 117,\n",
       "    'label': 'CCTV中国中央电视台-11戏曲',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11标清',\n",
       "    'channelid': 558,\n",
       "    'channelnumber': 118,\n",
       "    'label': 'CCTV中国中央电视台-11标清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-11高清',\n",
       "    'channelid': 1624,\n",
       "    'channelnumber': 119,\n",
       "    'label': 'CCTV中国中央电视台-11高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12',\n",
       "    'channelid': 45,\n",
       "    'channelnumber': 120,\n",
       "    'label': 'CCTV中国中央电视台-12',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12',\n",
       "    'channelid': 438,\n",
       "    'channelnumber': 121,\n",
       "    'label': 'CCTV中国中央电视台-12',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12 社会与法',\n",
       "    'channelid': 1567,\n",
       "    'channelnumber': 122,\n",
       "    'label': 'CCTV中国中央电视台-12 社会与法',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12 社会与法',\n",
       "    'channelid': 816,\n",
       "    'channelnumber': 123,\n",
       "    'label': 'CCTV中国中央电视台-12 社会与法',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12FHD',\n",
       "    'channelid': 1543,\n",
       "    'channelnumber': 124,\n",
       "    'label': 'CCTV中国中央电视台-12FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-12社会与法',\n",
       "    'channelid': 1130,\n",
       "    'channelnumber': 125,\n",
       "    'label': 'CCTV中国中央电视台-12社会与法',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13',\n",
       "    'channelid': 442,\n",
       "    'channelnumber': 126,\n",
       "    'label': 'CCTV中国中央电视台-13',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13',\n",
       "    'channelid': 1036,\n",
       "    'channelnumber': 127,\n",
       "    'label': 'CCTV中国中央电视台-13',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13',\n",
       "    'channelid': 690,\n",
       "    'channelnumber': 128,\n",
       "    'label': 'CCTV中国中央电视台-13',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13FHD',\n",
       "    'channelid': 390,\n",
       "    'channelnumber': 129,\n",
       "    'label': 'CCTV中国中央电视台-13FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13新闻',\n",
       "    'channelid': 822,\n",
       "    'channelnumber': 130,\n",
       "    'label': 'CCTV中国中央电视台-13新闻',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13标清',\n",
       "    'channelid': 1615,\n",
       "    'channelnumber': 131,\n",
       "    'label': 'CCTV中国中央电视台-13标清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-13高清',\n",
       "    'channelid': 1225,\n",
       "    'channelnumber': 132,\n",
       "    'label': 'CCTV中国中央电视台-13高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14',\n",
       "    'channelid': 200,\n",
       "    'channelnumber': 133,\n",
       "    'label': 'CCTV中国中央电视台-14',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14',\n",
       "    'channelid': 1616,\n",
       "    'channelnumber': 134,\n",
       "    'label': 'CCTV中国中央电视台-14',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14',\n",
       "    'channelid': 308,\n",
       "    'channelnumber': 135,\n",
       "    'label': 'CCTV中国中央电视台-14',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14 少儿',\n",
       "    'channelid': 727,\n",
       "    'channelnumber': 136,\n",
       "    'label': 'CCTV中国中央电视台-14 少儿',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14 少儿频道',\n",
       "    'channelid': 1076,\n",
       "    'channelnumber': 137,\n",
       "    'label': 'CCTV中国中央电视台-14 少儿频道',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14FHD',\n",
       "    'channelid': 62,\n",
       "    'channelnumber': 138,\n",
       "    'label': 'CCTV中国中央电视台-14FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14HD',\n",
       "    'channelid': 1451,\n",
       "    'channelnumber': 139,\n",
       "    'label': 'CCTV中国中央电视台-14HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-14少儿',\n",
       "    'channelid': 1378,\n",
       "    'channelnumber': 140,\n",
       "    'label': 'CCTV中国中央电视台-14少儿',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15',\n",
       "    'channelid': 129,\n",
       "    'channelnumber': 141,\n",
       "    'label': 'CCTV中国中央电视台-15',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15',\n",
       "    'channelid': 72,\n",
       "    'channelnumber': 142,\n",
       "    'label': 'CCTV中国中央电视台-15',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15',\n",
       "    'channelid': 1190,\n",
       "    'channelnumber': 143,\n",
       "    'label': 'CCTV中国中央电视台-15',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15',\n",
       "    'channelid': 975,\n",
       "    'channelnumber': 144,\n",
       "    'label': 'CCTV中国中央电视台-15',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15标清',\n",
       "    'channelid': 649,\n",
       "    'channelnumber': 145,\n",
       "    'label': 'CCTV中国中央电视台-15标清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-15音乐',\n",
       "    'channelid': 1033,\n",
       "    'channelnumber': 146,\n",
       "    'label': 'CCTV中国中央电视台-15音乐',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1FHD',\n",
       "    'channelid': 1318,\n",
       "    'channelnumber': 147,\n",
       "    'label': 'CCTV中国中央电视台-1FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1HD',\n",
       "    'channelid': 1180,\n",
       "    'channelnumber': 148,\n",
       "    'label': 'CCTV中国中央电视台-1HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1HD',\n",
       "    'channelid': 1657,\n",
       "    'channelnumber': 149,\n",
       "    'label': 'CCTV中国中央电视台-1HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1综合HD',\n",
       "    'channelid': 1352,\n",
       "    'channelnumber': 150,\n",
       "    'label': 'CCTV中国中央电视台-1综合HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1高清',\n",
       "    'channelid': 148,\n",
       "    'channelnumber': 151,\n",
       "    'label': 'CCTV中国中央电视台-1高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1高清',\n",
       "    'channelid': 145,\n",
       "    'channelnumber': 152,\n",
       "    'label': 'CCTV中国中央电视台-1高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-1高清',\n",
       "    'channelid': 1022,\n",
       "    'channelnumber': 153,\n",
       "    'label': 'CCTV中国中央电视台-1高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2',\n",
       "    'channelid': 1652,\n",
       "    'channelnumber': 154,\n",
       "    'label': 'CCTV中国中央电视台-2',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2',\n",
       "    'channelid': 1147,\n",
       "    'channelnumber': 155,\n",
       "    'label': 'CCTV中国中央电视台-2',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2FHD',\n",
       "    'channelid': 1611,\n",
       "    'channelnumber': 156,\n",
       "    'label': 'CCTV中国中央电视台-2FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2财经',\n",
       "    'channelid': 1044,\n",
       "    'channelnumber': 157,\n",
       "    'label': 'CCTV中国中央电视台-2财经',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2财经',\n",
       "    'channelid': 1158,\n",
       "    'channelnumber': 158,\n",
       "    'label': 'CCTV中国中央电视台-2财经',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2高清',\n",
       "    'channelid': 1568,\n",
       "    'channelnumber': 159,\n",
       "    'label': 'CCTV中国中央电视台-2高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2高清',\n",
       "    'channelid': 1079,\n",
       "    'channelnumber': 160,\n",
       "    'label': 'CCTV中国中央电视台-2高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-2高清',\n",
       "    'channelid': 388,\n",
       "    'channelnumber': 161,\n",
       "    'label': 'CCTV中国中央电视台-2高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3',\n",
       "    'channelid': 958,\n",
       "    'channelnumber': 162,\n",
       "    'label': 'CCTV中国中央电视台-3',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3HD',\n",
       "    'channelid': 890,\n",
       "    'channelnumber': 163,\n",
       "    'label': 'CCTV中国中央电视台-3HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3综艺HD',\n",
       "    'channelid': 1113,\n",
       "    'channelnumber': 164,\n",
       "    'label': 'CCTV中国中央电视台-3综艺HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3高清',\n",
       "    'channelid': 161,\n",
       "    'channelnumber': 165,\n",
       "    'label': 'CCTV中国中央电视台-3高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3高清',\n",
       "    'channelid': 578,\n",
       "    'channelnumber': 166,\n",
       "    'label': 'CCTV中国中央电视台-3高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-3高清',\n",
       "    'channelid': 1675,\n",
       "    'channelnumber': 167,\n",
       "    'label': 'CCTV中国中央电视台-3高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4',\n",
       "    'channelid': 1512,\n",
       "    'channelnumber': 168,\n",
       "    'label': 'CCTV中国中央电视台-4',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4',\n",
       "    'channelid': 1601,\n",
       "    'channelnumber': 169,\n",
       "    'label': 'CCTV中国中央电视台-4',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4',\n",
       "    'channelid': 255,\n",
       "    'channelnumber': 170,\n",
       "    'label': 'CCTV中国中央电视台-4',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4中文国际',\n",
       "    'channelid': 949,\n",
       "    'channelnumber': 171,\n",
       "    'label': 'CCTV中国中央电视台-4中文国际',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4中文国际 美洲',\n",
       "    'channelid': 1660,\n",
       "    'channelnumber': 172,\n",
       "    'label': 'CCTV中国中央电视台-4中文国际 美洲',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-4高清',\n",
       "    'channelid': 1552,\n",
       "    'channelnumber': 173,\n",
       "    'label': 'CCTV中国中央电视台-4高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5',\n",
       "    'channelid': 1133,\n",
       "    'channelnumber': 174,\n",
       "    'label': 'CCTV中国中央电视台-5',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5',\n",
       "    'channelid': 1677,\n",
       "    'channelnumber': 175,\n",
       "    'label': 'CCTV中国中央电视台-5',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5+',\n",
       "    'channelid': 1148,\n",
       "    'channelnumber': 176,\n",
       "    'label': 'CCTV中国中央电视台-5+',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5+ 体育赛事频道',\n",
       "    'channelid': 807,\n",
       "    'channelnumber': 177,\n",
       "    'label': 'CCTV中国中央电视台-5+ 体育赛事频道',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5+HD',\n",
       "    'channelid': 1562,\n",
       "    'channelnumber': 178,\n",
       "    'label': 'CCTV中国中央电视台-5+HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5+体育赛事HD',\n",
       "    'channelid': 806,\n",
       "    'channelnumber': 179,\n",
       "    'label': 'CCTV中国中央电视台-5+体育赛事HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5FHD',\n",
       "    'channelid': 1618,\n",
       "    'channelnumber': 180,\n",
       "    'label': 'CCTV中国中央电视台-5FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5体育HD',\n",
       "    'channelid': 545,\n",
       "    'channelnumber': 181,\n",
       "    'label': 'CCTV中国中央电视台-5体育HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-5高清',\n",
       "    'channelid': 923,\n",
       "    'channelnumber': 182,\n",
       "    'label': 'CCTV中国中央电视台-5高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6',\n",
       "    'channelid': 399,\n",
       "    'channelnumber': 183,\n",
       "    'label': 'CCTV中国中央电视台-6',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6HD',\n",
       "    'channelid': 529,\n",
       "    'channelnumber': 184,\n",
       "    'label': 'CCTV中国中央电视台-6HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6电影',\n",
       "    'channelid': 674,\n",
       "    'channelnumber': 185,\n",
       "    'label': 'CCTV中国中央电视台-6电影',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6电影HD',\n",
       "    'channelid': 1426,\n",
       "    'channelnumber': 186,\n",
       "    'label': 'CCTV中国中央电视台-6电影HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6高清',\n",
       "    'channelid': 1540,\n",
       "    'channelnumber': 187,\n",
       "    'label': 'CCTV中国中央电视台-6高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6高清',\n",
       "    'channelid': 1574,\n",
       "    'channelnumber': 188,\n",
       "    'label': 'CCTV中国中央电视台-6高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-6高清',\n",
       "    'channelid': 1034,\n",
       "    'channelnumber': 189,\n",
       "    'label': 'CCTV中国中央电视台-6高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7',\n",
       "    'channelid': 1376,\n",
       "    'channelnumber': 190,\n",
       "    'label': 'CCTV中国中央电视台-7',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7FHD',\n",
       "    'channelid': 1006,\n",
       "    'channelnumber': 191,\n",
       "    'label': 'CCTV中国中央电视台-7FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7HD',\n",
       "    'channelid': 598,\n",
       "    'channelnumber': 192,\n",
       "    'label': 'CCTV中国中央电视台-7HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7军事农业',\n",
       "    'channelid': 978,\n",
       "    'channelnumber': 193,\n",
       "    'label': 'CCTV中国中央电视台-7军事农业',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7军事农业',\n",
       "    'channelid': 1240,\n",
       "    'channelnumber': 194,\n",
       "    'label': 'CCTV中国中央电视台-7军事农业',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7高清',\n",
       "    'channelid': 1281,\n",
       "    'channelnumber': 195,\n",
       "    'label': 'CCTV中国中央电视台-7高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-7高清',\n",
       "    'channelid': 180,\n",
       "    'channelnumber': 196,\n",
       "    'label': 'CCTV中国中央电视台-7高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8',\n",
       "    'channelid': 686,\n",
       "    'channelnumber': 197,\n",
       "    'label': 'CCTV中国中央电视台-8',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8',\n",
       "    'channelid': 589,\n",
       "    'channelnumber': 198,\n",
       "    'label': 'CCTV中国中央电视台-8',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8HD',\n",
       "    'channelid': 735,\n",
       "    'channelnumber': 199,\n",
       "    'label': 'CCTV中国中央电视台-8HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8HD',\n",
       "    'channelid': 901,\n",
       "    'channelnumber': 200,\n",
       "    'label': 'CCTV中国中央电视台-8HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8电视剧',\n",
       "    'channelid': 294,\n",
       "    'channelnumber': 201,\n",
       "    'label': 'CCTV中国中央电视台-8电视剧',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8电视剧HD',\n",
       "    'channelid': 350,\n",
       "    'channelnumber': 202,\n",
       "    'label': 'CCTV中国中央电视台-8电视剧HD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8高清',\n",
       "    'channelid': 1527,\n",
       "    'channelnumber': 203,\n",
       "    'label': 'CCTV中国中央电视台-8高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8高清',\n",
       "    'channelid': 1094,\n",
       "    'channelnumber': 204,\n",
       "    'label': 'CCTV中国中央电视台-8高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-8高清',\n",
       "    'channelid': 1687,\n",
       "    'channelnumber': 205,\n",
       "    'label': 'CCTV中国中央电视台-8高清',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9',\n",
       "    'channelid': 952,\n",
       "    'channelnumber': 206,\n",
       "    'label': 'CCTV中国中央电视台-9',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9',\n",
       "    'channelid': 774,\n",
       "    'channelnumber': 207,\n",
       "    'label': 'CCTV中国中央电视台-9',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9',\n",
       "    'channelid': 699,\n",
       "    'channelnumber': 208,\n",
       "    'label': 'CCTV中国中央电视台-9',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9 纪录',\n",
       "    'channelid': 1604,\n",
       "    'channelnumber': 209,\n",
       "    'label': 'CCTV中国中央电视台-9 纪录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9FHD',\n",
       "    'channelid': 1003,\n",
       "    'channelnumber': 210,\n",
       "    'label': 'CCTV中国中央电视台-9FHD',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9纪录',\n",
       "    'channelid': 467,\n",
       "    'channelnumber': 211,\n",
       "    'label': 'CCTV中国中央电视台-9纪录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9英',\n",
       "    'channelid': 1495,\n",
       "    'channelnumber': 212,\n",
       "    'label': 'CCTV中国中央电视台-9英',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9记录',\n",
       "    'channelid': 692,\n",
       "    'channelnumber': 213,\n",
       "    'label': 'CCTV中国中央电视台-9记录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9记录',\n",
       "    'channelid': 1026,\n",
       "    'channelnumber': 214,\n",
       "    'label': 'CCTV中国中央电视台-9记录',\n",
       "    'subchannelnumber': 0},\n",
       "   {'channel': 'CCTV中国中央电视台-9高清',\n",
       "    'channelid': 1035,\n",
       "    'channelnumber': 215,\n",
       "    'label': 'CCTV中国中央电视台-9高清',\n",
       "    'subchannelnumber': 0}],\n",
       "  'limits': {'end': 215, 'start': 0, 'total': 215}}}"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters4 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"PVR.GetChannels\", \n",
    "              \"params\": {\n",
    "                  \"channelgroupid\":2,\n",
    "                  \"properties\":[\"channel\", \"channelnumber\", \"subchannelnumber\"]\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result4= requests.post(url,json=parameters4,auth=(\"kodi\",\"kodi\")).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# sony tv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [[{'uri': 'extInput:hdmi?port=1', 'title': 'HDMI 1', 'index': 0},\n",
       "   {'uri': 'extInput:hdmi?port=2', 'title': 'HDMI 2', 'index': 1},\n",
       "   {'uri': 'extInput:hdmi?port=3', 'title': 'HDMI 3/ARC', 'index': 2},\n",
       "   {'uri': 'extInput:hdmi?port=4', 'title': 'HDMI 4', 'index': 3}]],\n",
       " 'id': 88}"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.174:80/sony/avContent'\n",
    "parameters4 = {\n",
    "    \"method\": \"getContentList\",\n",
    "    \"id\": 88,\n",
    "    \"params\": [{\n",
    "        \"stIdx\": 0,\n",
    "        \"cnt\": 50,\n",
    "        \"uri\": \"extInput:hdmi\"\n",
    "    }],\n",
    "    \"version\": \"1.5\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [0], 'id': 601}"
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设定音量\n",
    "url = 'http://192.168.2.174:80/sony/audio'\n",
    "parameters4 = {\n",
    "    \"method\": \"setAudioVolume\",\n",
    "    \"id\": 601,\n",
    "    \"params\": [{\n",
    "        \"volume\": \"10\",\n",
    "        \"target\": \"speaker\"\n",
    "    }],\n",
    "    \"version\": \"1.0\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header).json()\n",
    "result4       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [], 'id': 101}"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设定信号源\n",
    "url = 'http://192.168.2.174:80/sony/avContent'\n",
    "parameters4 = {\n",
    "    \"method\": \"setPlayContent\",\n",
    "    \"id\": 101,\n",
    "    \"params\": [{\"uri\": \"extInput:hdmi?port=2\"}],\n",
    "    \"version\": \"1.0\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'status': 'active'}], 'id': 50}"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 当前电源状态\n",
    "url = 'http://192.168.2.174:80/sony/system'\n",
    "parameters4 = {\n",
    "    \"method\": \"getPowerStatus\",\n",
    "    \"id\": 50,\n",
    "    \"params\": [],\n",
    "    \"version\": \"1.0\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header).json()\n",
    "result4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [], 'id': 55}"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 关机或开机\n",
    "url = 'http://192.168.2.174:80/sony/system'\n",
    "parameters4 = {\n",
    "    \"method\": \"setPowerStatus\",\n",
    "    \"id\": 55,\n",
    "    \"params\": [{\"status\": True}],\n",
    "    \"version\": \"1.0\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header).json()\n",
    "result4       "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': [{'product': 'TV',\n",
       "   'region': 'CHN',\n",
       "   'language': 'chi',\n",
       "   'model': 'KD-55X8000E',\n",
       "   'serial': '2070602',\n",
       "   'macAddr': '04:5D:4B:D9:6F:20',\n",
       "   'name': 'BRAVIA',\n",
       "   'generation': '5.2.0',\n",
       "   'area': 'CHN',\n",
       "   'cid': 'C29F00B348929B5E364108E5C8400A004583C740E5D0F8B7539F11E9D97EB0F2'}],\n",
       " 'id': 33}"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 唤醒用的\n",
    "url = 'http://192.168.2.174:80/sony/system'\n",
    "parameters4 = {\n",
    "    \"method\": \"getSystemInformation\",\n",
    "    \"id\": 33,\n",
    "    \"params\": [],\n",
    "    \"version\": \"1.0\"\n",
    "             }\n",
    "header = {\n",
    "    'X-Auth-PSK':'cqzhao'\n",
    "}\n",
    "result4= requests.post(url,json=parameters4,headers=header,timeout=1).json()\n",
    "result4   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Can't connect list index out of range\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(None, None, None)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username = 'kodi'\n",
    "password= 'kodi'\n",
    "def get_playing():\n",
    "    parameters6 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.GetActivePlayers\", \n",
    "              \"params\": {                  \n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "    try:\n",
    "        result6= requests.post(url,json=parameters6,auth=(username,password)).json()\n",
    "        playerid = result6[\"result\"][0][\"playerid\"]\n",
    "        print(playerid)\n",
    "        parameters7 = {\n",
    "                \"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \n",
    "                \"params\": {\n",
    "                    \"playerid\":playerid,\n",
    "                    \"properties\":[ \"season\", \"episode\",\"showtitle\"]\n",
    "                    }, \n",
    "                \"id\": 1\n",
    "                }\n",
    "        result7 = requests.post(url,json=parameters7,auth=(username,password)).json()\n",
    "        showtitle = result7['result']['item']['showtitle']\n",
    "        nseason = result7['result']['item']['season']\n",
    "        nepisode = result7['result']['item']['episode']\n",
    "        return showtitle,nseason,nepisode\n",
    "    except Exception as e:\n",
    "        print(\"Can't connect\",e)\n",
    "        return None,None,None\n",
    "get_playing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1,\n",
       " 'jsonrpc': '2.0',\n",
       " 'result': {'item': {'episode': 3,\n",
       "   'id': 821,\n",
       "   'label': 's03e03',\n",
       "   'season': 3,\n",
       "   'showtitle': '宋飞正传',\n",
       "   'type': 'episode'}}}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "playerid=1\n",
    "parameters7 = {\n",
    "                \"jsonrpc\": \"2.0\", \"method\": \"Player.GetItem\", \n",
    "                \"params\": {\n",
    "                    \"playerid\":playerid,\n",
    "                    \"properties\":[ \"season\", \"episode\",\"showtitle\"]\n",
    "                    }, \n",
    "                \"id\": 1\n",
    "                }\n",
    "result7 = requests.post(url,json=parameters7,auth=(username,password)).json()\n",
    "result7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 'OK'}"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'http://192.168.2.138:8080/jsonrpc'\n",
    "parameters5 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.Stop\", \n",
    "              \"params\": {\n",
    "                  \"playerid\":1\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result5= requests.post(url,json=parameters5,auth=(\"kodi\",\"kodi\")).json()\n",
    "result5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "parameters7 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"Player.PlayPause\", \n",
    "              \"params\": {\n",
    "                  \"playerid\":1\n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "result7= requests.post(url,json=parameters7,auth=(\"kodi\",\"kodi\")).json()\n",
    "result7"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 1, 'jsonrpc': '2.0', 'result': 'OK'}"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def scan_library():\n",
    "    parameters6 = {\n",
    "              \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \n",
    "              \"params\": {                  \n",
    "                }, \n",
    "              \"id\": 1\n",
    "             }\n",
    "\n",
    "    result6= requests.post(url,json=parameters6,auth=(\"kodi\",\"kodi\")).json()\n",
    "    return result6[\"result\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老友记第5季10集\n",
      "('老友记', '5季10')\n",
      "老友记\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['老友记', None, '5季10']"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "def parse_play(command):\n",
    "    tvshow = None\n",
    "    season = None\n",
    "    episode = None\n",
    "    pattern = re.compile(\"播放(.*)\")\n",
    "    pattern_episode = re.compile(\"(.*)第(.*)集\")\n",
    "    pattern_season = re.compile(\"(.*)第(.*)季\")\n",
    "    match_play = pattern.search(command)\n",
    "    if match_play:\n",
    "        whatplay = match_play.groups()[0]\n",
    "        print(whatplay)\n",
    "        match_episode = pattern_episode.search(whatplay)\n",
    "        print(match_episode.groups())\n",
    "        if match_episode:\n",
    "            episode = match_episode.groups()[1]\n",
    "            whatplay = match_episode.groups()[0]\n",
    "            print(whatplay)\n",
    "        match_season = pattern_season.search(whatplay)\n",
    "        if match_season:\n",
    "            season = match_season.groups()[1]\n",
    "            tvshow = match_season.groups()[0]\n",
    "        else:\n",
    "            tvshow = whatplay\n",
    "        return [tvshow,season,episode]\n",
    "    else:\n",
    "        # 没找到播放关键字\n",
    "        return None\n",
    "com = \"播放老友记第5季10集\"\n",
    "parse_play(com)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('老友记第5季', '10')"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "whatplay = \"老友记第5季第10集\"\n",
    "pattern_episode = re.compile(\"(.*)第(.*)集\")\n",
    "match_episode = pattern_episode.search(whatplay)\n",
    "match_episode.groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(None, 1)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def parse_offset(command):\n",
    "    # parse 上一集/下一集\n",
    "    tvshow = None\n",
    "    offset = 0\n",
    "    pattern_pre = re.compile(\"上一集(.*)\")\n",
    "    pattern_next = re.compile(\"下一集(.*)\")\n",
    "    match_pre = pattern_pre.search(command)\n",
    "    match_next = pattern_next.search(command)\n",
    "    if match_pre:\n",
    "        offset = -1\n",
    "        try:\n",
    "            tvshow = match_pre.groups()[0]\n",
    "        except IndexError:\n",
    "            tvshow = None\n",
    "    if match_next:\n",
    "        offset = 1\n",
    "        try:\n",
    "            tvshow = match_next.groups()[0]\n",
    "            if tvshow == \"\":\n",
    "                tvshow = None\n",
    "        except IndexError:\n",
    "            tvshow = None\n",
    "    return tvshow,offset\n",
    "parse_offset(\"下一集\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "('',)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "command = \"下一集\"\n",
    "pattern_next = re.compile(\"下一集(.*)\")\n",
    "match_next = pattern_next.search(command)\n",
    "match_next.groups()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def number(n_str:str) -> int:\n",
    "    # turn string number into int, string number could be chinese character\n",
    "    chinese_num = [\"零\",\"一\",\"二\",\"三\",\"四\",\"五\",\"六\",\"七\",\"八\",\"九\",\"十\",\"百\",\"千\",\"万\"]\n",
    "    num  = [0,1,2,3,4,5,6,7,8,9,10,100,1000,10000]\n",
    "    try:\n",
    "        result = int(n_str)\n",
    "    except ValueError:\n",
    "        # for chinese character\n",
    "        num_digit = [] # 位上的数字\n",
    "        num_multy = [] # 乘子\n",
    "        for i,istr in enumerate(n_str):\n",
    "            try:\n",
    "                if chinese_num.index(istr)<=9:\n",
    "                    num_digit.append(num[chinese_num.index(istr)])                          \n",
    "                else:\n",
    "                    num_multy.append(num[chinese_num.index(istr)])\n",
    "            except ValueError:\n",
    "                # the character is not in chinese_num,return 1 for robust\n",
    "                return 1\n",
    "            if i==len(n_str)-1:\n",
    "                num_multy.append(1)\n",
    "        num_digit = np.pad(np.array(num_digit),(len(num_multy)-len(num_digit),0),'constant',constant_values=1)\n",
    "        num_multy = np.array(num_multy)\n",
    "        result = np.dot(num_digit,num_multy)\n",
    "    return result\n",
    "\n",
    "number(\"十无\")\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'老爸老妈的浪漫史'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def parse_tvshow_name(name:str) ->str:\n",
    "    # 把口语上的剧集名字转换为数据库中的名字\n",
    "    oral_names = {\n",
    "        \"六人行\":\"老友记\",\n",
    "        \"寻妈记\":\"老爸老妈的浪漫史\",\n",
    "        \"老爸老妈\":\"老爸老妈的浪漫史\",\n",
    "        \"宋飞\":\"宋飞正传\",\n",
    "        \"爱死机\":\"爱，死亡和机器人\",\n",
    "        \"大臣\":\"是，大臣\",\n",
    "        \"首相\":\"是，首相\", \n",
    "    }\n",
    "    try:\n",
    "        database_name = oral_names[name]\n",
    "    except KeyError as e:\n",
    "        print(f\"{name} is not in oral names dict\")\n",
    "        database_name = name\n",
    "    return database_name\n",
    "\n",
    "parse_tvshow_name(\"寻妈记\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "六人行\n"
     ]
    },
    {
     "ename": "AttributeError",
     "evalue": "'NoneType' object has no attribute 'groups'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-57986ea27623>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;31m# print(parse_play(command2))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;31m# print(parse_play(command3))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mparse_play\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"播放六人行\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mget_episodeid\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcommand\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[0mresult\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mparse_play\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcommand\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m<ipython-input-9-cc8e9fea6a88>\u001b[0m in \u001b[0;36mparse_play\u001b[1;34m(command)\u001b[0m\n\u001b[0;32m     13\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwhatplay\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     14\u001b[0m         \u001b[0mmatch_episode\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpattern_episode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msearch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mwhatplay\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 15\u001b[1;33m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mmatch_episode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgroups\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     16\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mmatch_episode\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     17\u001b[0m             \u001b[0mepisode\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mmatch_episode\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgroups\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'NoneType' object has no attribute 'groups'"
     ]
    }
   ],
   "source": [
    "# print(parse_play(command))\n",
    "# print(parse_play(command2))\n",
    "# print(parse_play(command3))\n",
    "print(parse_play(\"播放六人行\"))\n",
    "def get_episodeid(command):\n",
    "    result = parse_play(command)\n",
    "    if result[0] is None:\n",
    "        return None,\"Error\"\n",
    "    else:\n",
    "        tvshow_name = parse_tvshow_name(result[0])\n",
    "        if tvshow_name in dict_all_tvshows.keys():\n",
    "            if result[1] is None:\n",
    "                # play random episode\n",
    "                pick = np.random.randint(0,len(dict_all_tvshows[tvshow_name]['detail']),size=(1))[0]\n",
    "                return dict_all_tvshows[tvshow_name]['detail'][pick][2],f\"播放{tvshow_name}第{dict_all_tvshows[tvshow_name]['detail'][pick][0]}季第{dict_all_tvshows[tvshow_name]['detail'][pick][1]}集\"\n",
    "            else:\n",
    "                ns = number(result[1])\n",
    "                if result[2] is None:\n",
    "                    # play random episode for the given season\n",
    "                    episodeid = np.random.choice(dict_all_tvshows[tvshow_name]['index'][f\"{ns:04d}\"])\n",
    "                    return episodeid,f\"播放{tvshow_name}第{ns}季第{dict_all_tvshows[tvshow_name]['index'][f'{ns:04d}'].index(episodeid)}集\"\n",
    "                else:\n",
    "                    # play given episode from given season                  \n",
    "                    ne = number(result[2])\n",
    "                    episodeid = dict_all_tvshows[tvshow_name]['index'][f'{ns:04d}'][ne-1]\n",
    "                    return episodeid,f\"播放{tvshow_name}第{ns}季第{ne}集\"\n",
    "\n",
    "        else:\n",
    "            return None,\"Error\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2570, '播放老友记第3季第5集')"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老友记 is not in oral names dict\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(2577, '播放老友记第3季第11集')"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "老友记 is not in oral names dict\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "(2547, '播放老友记第2季第6集')"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "command = \"播放六人行第三季第五集\"\n",
    "command2 = \"播放老友记第3季\"\n",
    "command3 = \"播放老友记第9集\"\n",
    "get_episodeid(command)\n",
    "get_episodeid(command2)\n",
    "get_episodeid(command3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'command': 'test'}"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "json.loads('{\"command\":\"test\"}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# yyf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': 'OK'}"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 菜单键\n",
    "url = \"http://192.168.2.107:8080/v1/keyevent\"\n",
    "parameters5 = {\n",
    "    \"keycode\":82,\n",
    "    \"longclick\":False \n",
    "             }\n",
    "\n",
    "result5= requests.post(url,json=parameters5).json()\n",
    "result5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'result': 'OK'}"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = \"http://192.168.2.107:8080/v1/action\"\n",
    "parameters5 = {\n",
    "\"action\":\"setting\"\n",
    "             }\n",
    "\n",
    "result5= requests.post(url,json=parameters5).json()\n",
    "result5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 84,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "int()"
   ]
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
